//
//  TSCMyAutoCompleteSearchBar.h
//  Tsc_IOS
//
//  Created by Rio on 15-6-1.
//  Copyright (c) 2015年 idream. All rights reserved.
//

typedef UITableViewCell * (^BCellCreator)(UITableView *, NSIndexPath *);
typedef void(^BItemSelectedListener)(NSIndexPath *);
typedef void(^BTextDidChangeListener)(UISearchBar * searchBar, NSString * searchText);
typedef void(^BSearchBtnClickedListener)(UISearchBar * searchBar);

#import <UIKit/UIKit.h>

@interface TSCMyAutoCompleteSearchBar : UIView <UISearchBarDelegate, UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, copy) NSString * placeholder;
@property (nonatomic, copy) NSString * text;

@property (nonatomic, strong) NSMutableArray * dataArray;
@property (nonatomic, strong) BCellCreator cellCreator;
@property (nonatomic, strong) BItemSelectedListener itemSelectedListener;
@property (nonatomic, strong) BTextDidChangeListener textDidChangeListener;
@property (nonatomic, strong) BSearchBtnClickedListener searchBtnClickedListener;

- (void) prepareData_P1:(void(^)())preparingHandler completionHandler:(void(^)())completionHandler;
- (void) cleanData;
- (void) applyData;
- (void) showTable;
- (void) dismissTable;
- (BOOL) isTableShowing;
- (BOOL) isPerformingCompletion;
- (void) resignFirstResponder; // 关闭弹出键盘
- (NSIndexPath *) getSelectedIndexPath;
- (id) getSelectedObject;

@end
